<include file="public@header" />
<style type="text/css">
    .form-search label{width:300px;}
    .form-search label.date{width:300px;}
    .form-search input.js-date{width:80px;}
    .form-search select{width:auto !important;}
    .groups{overflow:hidden; width:46%; border-right:1px double #0b7ebf; float:left; margin-bottom:50px; padding:4%;}
    .groups1{overflow:hidden; width:45%; float:left}
    .control-group{/*width:95%; margin:5px 5% 5px 0; overflow:hidden; border-bottom:1px dashed #eee*/ }
    .control-group1{width:90%; margin:10px 5%; overflow:hidden; border-bottom:1px dashed #eee}
    .control-group label{ width:50%; float:left}

    .control-group1 label{ width:100%; float:left}
    .form-horizontal .control-group1 {
        float: left;
        width: 25%;
        margin-bottom: 20px;
    }
    .minwidth{max-width:45px !important}
    .form-horizontal .control-label {width:100px;}
    .form-horizontal .controls {margin-left:110px;}
    input,select, textarea, .uneditable-input {
        /*max-width: 200px;*/
        width:auto;
        /*min-width:176px;*/
    }
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li><a href="{:url('orders/visua')}">{:lang('可视化墓区')}</a></li>
        <li  class="active"><a href="">墓位信息</a></li>
    </ul>
    <form  class="form-horizontal js-ajax-form" method="post" action="{:url('Orders/sale')}" enctype="multipart/form-data" style="width:80%;float:left;">
        <fieldset>
            <div class="p_title">
                <span class="span_title">墓位详情</span>
            </div>
            <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;">
                <div class="control-group1" >
                    <label class="control-label">葬式:</label>
                    <div class="controls">
                        <select class="form-control" name="tomb[funeral]" >
                            <foreach name="tomb_funeral.sp" item="vo">
                                <option value="{$vo}" <if condition="$vo eq  $result['funeral'] ">selected </if>>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="control-group1"  >
                    <label class="control-label">占地长度:</label>
                    <div class="controls">
                        <input type="text" class="form-control" name="footprint" style="width: 100px;" value="{$result.footprint|default=''}" disabled>mm
                    </div>
                </div>
                <div class="control-group1" >
                    <label class="control-label">占地宽度:</label>
                    <div class="controls">
                        <input type="text" class="form-control" name="tombstone_w" style="width: 100px;"value="{$result.tombstone_w|default=''}" disabled>mm
                    </div>
                </div>
                <div class="control-group1" >
                    <label class="control-label">墓碑高度:</label>
                    <div class="controls">
                        <input type="text" class="form-control" name="tombstone_h"style="width: 100px;"value="{$result.tombstone_h|default=''}" disabled>mm
                    </div>
                </div>
                <div class="control-group1"  >
                    <label class="control-label">墓穴规制:</label>
                    <div class="controls">
                        <select class="form-control" name="tomb_regulation" disabled>
                            <foreach name="tomb_regulation" item="vo">
                                    <option value="{$vo.id}" <if condition="$vo.id eq  $result['tomb_regulation'] ">selected </if>>{$vo.name}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="control-group1" >
                    <label class="control-label">收敛形式:</label>
                    <div class="controls">
                        <select class="form-control" name="tomb[convergence]" >
                            <foreach name="tomb_convergence.sp" item="vo">
                                    <option value="{$vo}" <if condition="$vo eq  $result['convergence'] ">selected </if>>{$vo}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="control-group1"  >
                    <label class="control-label">单穴最大尺寸:</label>
                    <div class="controls">
                        <input type="text" class="form-control" disabled value="{$result.sc_width|default='0'}*{$result.sc_height|default='0'}*{$result.sc_thick|default=' '}" style="width: 130px;" > mm

                    </div>
                </div>
                <div class="control-group1" style="width: 20%;">
                    <label class="control-label">拜道规格:</label>
                    <div class="controls">
                        <input type="text" class="form-control " name="specifications"style="width: 120px;" placeholder="长*宽" value="{$result.specifications|default='10*10'}" disabled> mm
                    </div>
                </div>
                <div class="control-group1" >
                    <label class="control-label">绿化带规格:</label>
                    <div class="controls">
                        <input type="text" class="form-control " name="green_belt"   placeholder="长*宽" value="{$result.green_belt|default='10*10'}" disabled> mm
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">类型</label>
                    <div class="controls">
                        <input type="text" class="form-control" name="" disabled value="{$cate_name}">
                    </div>
                </div>
                <div class="control-group1">
                    <label class="control-label">备注</label>
                    <div class="controls">
                        <textarea type="text" class="form-control" rows="2" cols="45" disabled style="width:400px;" name="remark" placeholder="输入墓位信息备注" >{$result.remark|default=''}</textarea>
                    </div>
                </div>
            </div>
            <div class="p_title">
                <span class="span_title">订单详情</span>
                <input type="hidden" name="order[order_id]" value="{$result.order_id|default=''}">
                <input type="hidden" name="order[tomb_product_id]" value="{$result.id}">
                <input type="hidden" name="order[tomb_type]" value="{$cate_id}">
                <input type="hidden" name="order[tomb_id]" value="{$result.colID|default=''}">
                <input type="hidden" name="order[tomb_num]" value="{$result.num|default=''}">
                <input type="hidden" name="order[orders_id]" value="{$orders_id|default=''}">
            </div>
            <div class="control-group1-p" style="border:1px solid #e2e2e2; padding-top:20px;">
                <div class="form-group">
                    <label class="control-label">墓位编号</label>
                    <div class="col-md-2">
                        <input type="text"  class="form-control" name="" value="{$result.num|default=''}" disabled>
                    </div>
                    <label class="control-label">所属区域</label>
                    <div class="col-md-2">
                        <input type="text"  class="form-control" name="tomb_region"  style="width: 100%" value="{$result.tomb_region|default=''}" disabled >
                    </div>
                    <label class="control-label">具体位置</label>
                    <div class="col-md-2">
                        <input type="text"  class="form-control" name="tomb_address" value="{$result.tomb_address|default=''}{$result.layer_num|default=''}层" disabled>
                    </div>
                    <label class="control-label">墓位状态</label>
                    <div class="col-md-2">
                        <input type="text"  class="form-control" name="tomb_status" value="{$result.tomb_status|default=''}" disabled >
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">销售价格</label>
                    <div class="col-md-2">
                        <input type="hidden" class="selling_price"  name="order[selling_price]" value="{$result.selling_price|default='0'}">
                        <input type="text"  class="form-control selling_price" value="{$result.selling_price|default=''}" disabled  style="width: 160px" >元/套
                    </div>
                    <label class="control-label">优惠减免</label>
                    <div class="col-md-2">
                        <input type="number" min="0" style="width: 80px;" class="form-control discount_ratio"  id="discount_ratio"  >%

                        <input type="hidden" class="form-control "  id="discount_ratio_"  name="order[discount_ratio]" value="{$result.discount_ratio|default='0'}">
                        <br><span style="color: #df0505; font-size: 2px">例:95折，输入5。默认为0</span>
                    </div>
                    <label class="control-label"style="">免零金额</label>
                    <div class="col-md-2" style=" ">
                        <input type="number" name="order[free_price]" min="0" max="100" class="form-control free_price" value="0" placeholder="100元以内" <if condition="$result.reacher">disabled <else/>    </if> >元
                    </div>
                    <label class="control-label">成交价格</label>
                    <div class="col-md-2">
                        <input type="hidden" class=" closing_price"   name="order[closing_price]" value="{$result.closing_price|default='0'}">
                        <input type="text" class="form-control closing_price"   disabled  value="{$result.closing_price|default='0'}"style="width: 160px">元/套
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label"  >导购员</label>
                    <div class="col-md-2" >
                        <input type="hidden"   name="order[shoppingguide]" value="{$result.shoppingguide}" >
                        <input type="text" class="form-control" name="shoppingguide" disabled value="{$result.shoppingguide_name}">
                    </div>
                    <label class="control-label" >代理商</label>
                    <div class="col-md-2"  >
                        <select name="order[agent_user]"  style="width: 100%"  class="form-control">
                            <option value="0">请选择</option>
                            <foreach name="dailishang_list" item="vou">
                                <if condition=" isset($result['agent_user'])">
                                    <option value="{$vou.id}" <if condition=" $result['agent_user'] eq $vou.id"> selected </if>>{$vou.department_name}-{$vou.user_nickname}</option>
                                    <else/>
                                    <option value="{$vou.id}">{$vou.department_name}-{$vou.user_nickname}</option>
                                </if>
                            </foreach>
                        </select>
                    </div>
                    <label class="control-label">抵顶人</label>
                    <div class="col-md-2" >
                        <input type="text" style="width: 100%"  class="form-control" name="reaching" value="{$result.reacher|default=''}" disabled >
                    </div>
                    <label class="control-label">经办人</label>
                    <div class="col-md-2" >
                        <input type="hidden"   name="order[handle]" value="{$result.handle|default=''}" >
                        <input type="text" style="width: 100%" class="form-control" name="handle" value="{$result.handle_name|default=''}" disabled>
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label">下单时间</label>
                    <div class="col-md-2"  >
                        <input type="hidden"   name="add_time" value="{$result.add_order_time}" >
                        <input type="text" style="width: 100%"  class="form-control js-date"  value="{$result.add_order_time}" disabled >
                    </div>

                </div>
            </div>
        </fieldset>
        <div class="form-actions" style="clear:both;">
            <button type="submit" class="btn btn-primary js-ajax-submit">下一步</button>
        </div>
    </form>
    <div style="width:20%; float:left">
        <php>$img_cer=cmf_get_image_preview_url(isset($result['tom_img'])?$result['tom_img']:'');$img_cer=$img_cer?$img_cer:'__TMPL__/public/assets/images/1.png'</php>
        <img src="{$img_cer}" class="preview" style="max-width:200px; display:block; margin:0 auto;"/>
    </div>
</div>

<script type="text/javascript" src="__STATIC__/js/admin.js?v={:time()}"></script>
<script type="text/javascript" src="__STATIC__/js/layer/layer.js"></script>
<script>
    $(function () {
        var discount_ratio_cs =  $('#discount_ratio_').val(); //优惠比例
        var selling_price = $('.selling_price').val(),
            free_price = $('.free_price').val();
        if (discount_ratio_cs==0){
            var closing_price = selling_price;
            $('#discount_ratio').val(0);
        } else {
            var discount_ratio = $('#discount_ratio_').val(),
            closing_price =(selling_price*(discount_ratio));
            $('#discount_ratio').val(100-(discount_ratio_cs*100));
        }
        $('.closing_price').val( parseFloat(closing_price-free_price).toFixed(2));

    })
    $('#discount_ratio').blur(function () {
        var discount_ratio = (100-$('#discount_ratio').val())/100,
            selling_price = $('.selling_price').val(),
            free_price = $('.free_price').val(),
            closing_price =selling_price*discount_ratio;

        $('.closing_price').val( parseFloat(closing_price-free_price).toFixed(2))
        $('#discount_ratio_').val(discount_ratio);
    })
    $('.free_price').blur(function () {
        var free_price  = $(this).val();
        if(free_price > 100) {
            layer.msg('减免金额不能超过100元');
        }else if (0 >free_price ){
            layer.msg('减免金额不能小于0元');
        }else {
            var discount_ratio = $('#discount_ratio_').val();
            var selling_price = $('.selling_price').val();
            console.log(selling_price)
            if (discount_ratio == 0){
                var receivable_price = selling_price - free_price;
            } else {
                var receivable_price = Number(
                    ((Number($('.selling_price').val().replace(/,/g, "")).toFixed(2)*1 )*discount_ratio)-
                    Number(free_price.replace(/,/g,"")).toFixed(2)*1
                );
            }
            $(".closing_price").val(receivable_price.toFixed(2));

        }
    })

</script>
</body>
</html>